home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / apps / 102 / examples / exlineac.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-01-25  |  4.7 KB  |  128 lines

  1. /* program found in MW-C ref.handbook pp.355-358                             */
  2. /* corrected using tip ; set XDDA @ 0x8000  before each use of linea8() ;    */
  3. /*
  4. /       module  name linea8;tip from "The ATARI St Explored",J.Braga,1986,p.199
  5.         .comm   la_init_,16
  6.         .shri
  7.         .globl  linea8_
  8. linea8_:
  9.         movea.l la_init_+4,a0
  10.         move    $-32768, 64(a0)             / preset XDDA BEFORE EACH USE
  11.         .word   0xa008
  12.         rts
  13.                                                                              */
  14. #include <stdio.h>                      /* include header files              */
  15. #include <osbind.h>                     /* for use of Getrez()               */
  16. #include <linea.h>                      /* for use of linea0()               */
  17. struct la_font *fontp;                  /* font pointer for linea interface  */
  18. char line[100], *p;
  19. char scr_wrk[2048];                     /*  area for graphics;double / mono  */
  20. int scr_fat, scr_chi;                   /*  length and disp. for underline   */
  21. /* FUNCTION                                put a character on the screen     */
  22. put_scr( c, x, y, mode)  int c,x,y,mode ;
  23. /* where        int c                             character to put out       */
  24. /*              int x, y                   x - y coordinates on 80*25 screen */
  25. /*              int mode *  0 normal                                         */
  26. /*                       *  1 thicken
  27.                          *  2 grey
  28.                          *  ...
  29.                          *  4 italic
  30.                          *  ...
  31.                          *  8 outline
  32.                          *  ...
  33.                          * 16 reverse
  34.                          *  ...
  35.                          * 32 underline                                      */
  36. {
  37.       unsigned int tmp;
  38.       static long patmsk = -1;
  39.       tmp = c - fontp->font_low_ade;
  40.       DELX = fontp->font_char_off[tmp+1] -
  41.             (SRCX = fontp->font_char_off[tmp]);
  42.       DSTX = x ;
  43.       DSTY = y ;
  44.       WMODE = 0;                                           /*  replace mode  */
  45.       STYLE = ( mode & 7 );
  46.       if(mode & 8)
  47.       {                                                    /*  reverse       */
  48.             X2 = (X1 = DSTX) + scr_fat;
  49.             Y2 = (Y1 = DSTY) + scr_chi;
  50.             PATPTR = & patmsk;
  51.             PATMSK = 1;
  52.             CLIP = 0;
  53.             linea5();                                      /*filled rectangle*/
  54.             WMODE = 2;                                     /* xor mode       */
  55.        }
  56.        if (mode & 16)
  57.        {    /* underline      */
  58.        X2 = (X1 = DSTX) + scr_fat;
  59.        Y2 =  Y1 = DSTY  + scr_chi;
  60.        linea8();
  61.        LNMASK = -1;
  62.        WMODE = 2;
  63.        linea3();
  64.        }
  65.        else
  66.        linea8();
  67. }
  68.  
  69. /*  FUNCTION             initialize stuff for screen                         */
  70. init_scr()
  71. {
  72.       linea0();                                    /*  initialize linea      */
  73.       lineaa();                                    /*  hide mouse            */
  74.       if( 2 == Getrez())
  75.       {
  76.                fontp = la_init.li_a1[2];               /*  8x16 system font  */
  77.       }
  78.       else
  79.       {
  80.                fontp = la_init.li_a1[1];                 /*  8x8 system font */
  81.       }
  82.       FBASE = fontp->font_data;
  83.       FWIDTH = fontp->font_width;
  84.       TEXTFG = 1;                                   /* text foreground white */
  85.       SRCY = 0;
  86.       DELY = fontp->font_height;
  87.       scr_fat = fontp->font_fatest;
  88.       scr_chi = fontp->font_height - 1;
  89.       COLBIT0 = 1;
  90.       COLBIT1 = 0;
  91.       COLBIT2 = 0;
  92.       COLBIT3 = 0;
  93. /*      XDDA  = 0x8000;Use new linea8 to set xaccdda to 0x8000 before each #8*/
  94.       LITEMSK = 0x5555;
  95.       SKEWMSK = 0x1111;
  96.       SCRTCHP = scr_wrk;
  97.       WEIGHT = 1;
  98.       LSTLIN = -1;
  99. }
  100.  
  101. init_msg()
  102. {
  103. printf("\033EProgram to demonstrate some linea capabilities;MWC-CJP OCT'86\n");
  104.       printf(" (Each line should have four decimal numbers or'quit')  \n");
  105.       printf("The  decimal   ASCII  value of the character 'A'==65, etc., \n");
  106.       printf("The X and Y coordinates:640x400,640x200,320x200 rez.screen ,\n");
  107.       printf("The  mode:     0=normal 1=thicken 2=gray 4=italic \n");
  108.       printf("               8=reverse 16=underline    \n");
  109. printf("Most combinations work but some are weird(Useing exlinea1.prg).\n \n");
  110. }
  111.  
  112. main()
  113. {
  114.        int c,x,y,m;
  115.        init_scr();
  116.        init_msg();
  117.        for(;;)
  118.        {
  119.              printf("\033A\033K> ");
  120.              fflush(stdout);
  121.              gets(line);
  122.              if(!strcmp(line, "quit"))
  123.                     return(0);
  124.              sscanf(line, "%d %d %d %d", &c, &x, &y, &m);
  125.              put_scr(c, x, y, m);
  126.        }
  127. }
  128.